import { Injectable } from '@nestjs/common';
import { Cat } from './interfaces/cat.interface';

// @Injectable() 装饰器附加元数据，该元数据声明 CatsService 是可由 Nest IoC 容器管理的类。
@Injectable()
export class CatsService {
  private readonly cats: Cat[] = [];

  create(cat: Cat) {
    this.cats.push(cat);
  }

  findOne(id: number): Cat {
    return this.cats[id];
  }

  findAll(): Cat[] {
    return this.cats;
  }
}
